static unsigned int get_domnr(void)
{
static unsigned int domnr = 0;
- return ++domnr;
+ do { domnr = (domnr+1) & ((1<<20)-1); }
+ while ( find_domain_by_id(domnr) != NULL );
+ return domnr;
}
static void build_page_list(struct task_struct *p)
case DOM0_STARTDOMAIN:
{
struct task_struct * p = find_domain_by_id(op.u.meminfo.domain);
+ ret = -EINVAL;
+ if ( (p == NULL) || !(p->flags & PF_CONSTRUCTED) )
+ break;
wake_up(p);
reschedule(p);
ret = p->domain;
p->domain = dom_id;
p->processor = cpu;
- sprintf (p->name, "Domain-%d", dom_id);
+ sprintf(p->name, "Domain-%d", dom_id);
spin_lock_init(&p->blk_ring_lock);
spin_lock_init(&p->page_lock);
net_vif_t *net_vif;
int i;
+ if ( (p->flags & PF_CONSTRUCTED) )
+ return -EINVAL;
+
/* High entries in page table must contain hypervisor
* mem mappings - set them up.
*/
virt_startinfo_addr->dom_id = p->domain;
virt_startinfo_addr->flags = IS_PRIV(p) ? SIF_PRIVILEGED : 0;
- if( virt_startinfo_addr->mod_len )
- printk("Initrd module present %08lx (%08lx)\n",
- virt_startinfo_addr->mod_start,
- virt_startinfo_addr->mod_len);
-
/* Add virtual network interfaces and point to them in startinfo. */
while (meminfo->num_vifs-- > 0) {
net_vif = create_net_vif(p->domain);
__asm__ __volatile__ (
"mov %%eax,%%cr3" : : "a" (pagetable_val(current->mm.pagetable)));
__sti();
+
+ p->flags |= PF_CONSTRUCTED;
new_thread(p,
(unsigned long)meminfo->virt_load_addr,
/* Sanity! */
if ( p->domain != 0 ) BUG();
+ if ( (p->flags & PF_CONSTRUCTED) ) BUG();
/*
* This is all a bit grim. We've moved the modules to the "safe" physical
__write_cr3_counted(pagetable_val(current->mm.pagetable));
__sti();
+ p->flags |= PF_CONSTRUCTED;
+
new_thread(p,
(unsigned long)virt_load_address,
(unsigned long)virt_stack_address,